﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>登录</title>
    <%@include file="/common/baselink.jsp"%>
    <link rel="stylesheet" href="${ctxPath }/assets/golbal/css/reset.css" />
	<link rel="stylesheet" href="${ctxPath }/assets/golbal/css/common.css" />
	<link rel="stylesheet" href="${ctxPath }/assets/golbal/css/font-awesome.min.css" />
    <script type="text/javascript">
    	if(window.top!==window.self){window.top.location=window.location};
	</script>
</head>
<body>
	<div class="wrap login_wrap">
		<div class="content">
			<div class="logo"></div>
			<div class="login_box">	
				
				<div class="login_form">
					<div class="login_title">
						登录
					</div>
					<form action="#" method="post">
						
						<div class="form_text_ipt">
							<input name="user_no" id="user_no" type="text" placeholder="登陆账号">
						</div>
						<div class="ececk_warning" id="errorUserNo"><span>登陆账号不能为空</span></div>
						<div class="form_text_ipt">
							<input name="user_pwd" id="user_pwd" type="password" placeholder="密码">
						</div>
						<div class="ececk_warning" id="errorUserPwd"><span>密码不能为空</span></div>
						<div class="form_check_ipt">
							<div class="left check_left">
								<label><input name="" type="checkbox"> 下次自动登录</label>
							</div>
							<div class="right check_right">
								<a href="#">忘记密码</a>
							</div>
						</div>
						<div class="form_btn">
							<button type="button" id="loginBtn" onclick="javascript:void(0);">登录</button>
						</div>
						<div class="form_reg_btn">
							<!-- <span>还没有帐号？</span><a href="register.html">马上注册</a> -->
							<span id="tips" style="color:#FF0000"></a>
						</div>
					</form>
					<div class="other_login">
						<div class="left other_left">
							<span>其它登录方式</span>
						</div>
						<div class="right other_right">
							<a href="#"><i class="fa fa-qq fa-2x"></i></a>
							<a href="#"><i class="fa fa-weixin fa-2x"></i></a>
							<a href="#"><i class="fa fa-weibo fa-2x"></i></a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
function validLoginForm(){
	if(Ext.isEmpty(Ext.get("user_no").getValue())){
		Ext.get("errorUserNo").show();
		Ext.get("user_no").focus();
		return false;
	}
	if(Ext.isEmpty(Ext.get("user_pwd").getValue())){
		Ext.get("errorUserPwd").show();
		Ext.get("user_pwd").focus();
		return false;
	}
	Ext.get("errorUserNo").hide();
	Ext.get("errorUserPwd").hide();
	return true;
}
function login(){
	if(!validLoginForm()){
		return;
	}
    var pwd_md5_key = Utils.md5(Ext.get("user_pwd").getValue());
	var pwd = Utils.encrypt(pwd_md5_key);
	AjaxUtils.CallService({
		url: CONTEXT.contextPath+"/v1/login",
		params: {
			"user_no": Ext.get("user_no").getValue(),
			"user_pwd": pwd
		},
		before: function(){
			document.getElementById("tips").innerHTML = "正在登陆......";
			return true;
		},
		call: function(data){
			if(data.status == "OK"){
				document.getElementById("tips").innerHTML = "登陆成功，正在进入系统......";
				window.location.href=CONTEXT.contextPath+"/index";

			}else{
				document.getElementById("tips").innerHTML = "登陆失败，请确认用户名或密码是否正确";
				AjaxUtils.showError('登陆失败，请确认用户名或密码是否正确');
			}
		}
	});
}
Ext.onReady(function() {
	Ext.getBody().on("keyup",function(source,e,eopts){
		if(source.getKey()==13){
			login();
		}
	});
	/* Ext.get("user_no").on("keyup",function(field,e,eopts){
		if(field.getKey()==13){
			login();
		}
	});
	Ext.get("user_pwd").on("keyup",function(field,e,eopts){
		if(field.getKey()==13){
			login();
		}
	}); */
	Ext.get("loginBtn").on("click",function(){
		login();
	});
});
</script>